#include<bits/stdc++.h>
#define ll long long
#define pr printf
#define sc scanf
using namespace std;
struct student
{
	int num;
	int de;
	int cai;
	int category;
	int sum;
};
struct student s[100005];
bool cmp(struct student a,struct student b)
{
	if(a.category==b.category){
		if(a.sum==b.sum){
			if(a.de==b.de)
				return a.num<b.num;
			return a.de>b.de;
		}
		return a.sum>b.sum;
	}
	return a.category<b.category;
}
int main()
{
	int i,n,l,h,cnt=0;
	sc("%d%d%d",&n,&l,&h);getchar();
	for(i=0;i<n;i++){
		sc("%d%d%d",&s[i].num,&s[i].de,&s[i].cai);
		s[i].sum=s[i].de+s[i].cai;
		if(s[i].de>=l&&s[i].cai>=l)
			cnt++;
		if(s[i].de>=h&&s[i].cai>=h)	
			s[i].category=1;
		else if(s[i].de>=h&&s[i].cai>=l)
			s[i].category=2;
		else if(s[i].de>=l&&s[i].cai>=l&&s[i].de>=s[i].cai)
			s[i].category=3;
		else if(s[i].de>=l&&s[i].cai>=l)
			s[i].category=4;
		else
			s[i].category=5;
	}
	sort(s,s+n,cmp);
	pr("%d\n",cnt);
	for(i=0;i<cnt;i++)
		pr("%d %d %d\n",s[i].num,s[i].de,s[i].cai);
	return 0;
}
